//
//  GoodsSpecificationsCell.m
//  MobileShoppingMall
//
//  Created by 冯传昌 on 2021/4/20.
//  Copyright © 2021 冯传昌. All rights reserved.
//

#import "GoodsSpecificationsCell.h"

@interface GoodsSpecificationsCell()<UIGestureRecognizerDelegate>

@property (nonatomic,strong) UILabel *leftSpecLB;//左侧lb  已选规格
@property (nonatomic,strong) UILabel *leftFreightLB;//左侧lb  运费
@property (nonatomic,strong) UILabel *leftDeliveryLB;//左侧lb  发货

@property (nonatomic,strong) UILabel *specLB;//lb  已选规格
@property (nonatomic,strong) UILabel *freightLB;//lb  运费
@property (nonatomic,strong) UILabel *deliveryLB;//lb  发货


@end

@implementation GoodsSpecificationsCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self initUI];
    }
    return self;
}

#pragma mark - setter
- (void)setCurrentSkuModel:(GoodsSkuModel *)currentSkuModel{
    _currentSkuModel = currentSkuModel;
    self.specLB.text = _currentSkuModel.norms;
    self.deliveryLB.text = @"";
}

#pragma mark - UI
-(void)initUI{
    [self.contentView addSubview:self.leftSpecLB];
    [self.contentView addSubview:self.leftFreightLB];
    [self.contentView addSubview:self.leftDeliveryLB];
    [self.contentView addSubview:self.specLB];
    [self.contentView addSubview:self.freightLB];
    [self.contentView addSubview:self.deliveryLB];
    
    UIView *lineV = [[UIView alloc] initWithFrame:CGRectMake(0, self.deliveryLB.bottom+30, ScreenWidth, 12)];
    lineV.backgroundColor = MainBackColor;
    [self.contentView addSubview:lineV];
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        if (self.updateCellHeightBlock) {
            self.updateCellHeightBlock(lineV.bottom);
        }
    });
}
#pragma mark - lazy
- (UILabel *)leftSpecLB{
    if (!_leftSpecLB) {
        _leftSpecLB = [[UILabel alloc] initWithFrame:CGRectMake(15, 20, 32, 20)];
        _leftSpecLB.font = FontSet(14);
        _leftSpecLB.textColor = MainGrayTextColor;
        _leftSpecLB.textAlignment = NSTextAlignmentLeft;
        _leftSpecLB.text = @"已选";
    }
    return _leftSpecLB;
}

- (UILabel *)leftFreightLB{
    if (!_leftFreightLB) {
        _leftFreightLB = [[UILabel alloc] initWithFrame:CGRectMake(self.leftSpecLB.left, self.leftSpecLB.bottom+25, 32, 20)];
        _leftFreightLB.font = FontSet(14);
        _leftFreightLB.textColor = MainGrayTextColor;
        _leftFreightLB.textAlignment = NSTextAlignmentLeft;
        _leftFreightLB.text = @"运费";
    }
    return _leftFreightLB;
}

- (UILabel *)leftDeliveryLB{
    if (!_leftDeliveryLB) {
        _leftDeliveryLB = [[UILabel alloc] initWithFrame:CGRectMake(self.leftFreightLB.left, self.leftFreightLB.bottom+25, 32, 20)];
        _leftDeliveryLB.font = FontSet(14);
        _leftDeliveryLB.textColor = MainGrayTextColor;
        _leftDeliveryLB.textAlignment = NSTextAlignmentLeft;
        _leftDeliveryLB.text = @"发货";
    }
    return _leftDeliveryLB;
}
//商品规格
- (UILabel *)specLB{
    if (!_specLB) {
        _specLB = [[UILabel alloc] initWithFrame:CGRectMake(self.leftSpecLB.right+20, self.leftSpecLB.top, ScreenWidth-110, 20)];
        _specLB.font = FontSet(14);
        _specLB.textColor = MainBlackTextColor;
        _specLB.textAlignment = NSTextAlignmentLeft;
        _specLB.text = @"";
        _specLB.userInteractionEnabled = YES;
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapClick:)];
        tap.delegate = self;
        [_specLB addGestureRecognizer:tap];
    }
    return _specLB;
}
//运费
- (UILabel *)freightLB{
    if (!_freightLB) {
        _freightLB = [[UILabel alloc] initWithFrame:CGRectMake(self.leftFreightLB.right+20, self.leftFreightLB.top, ScreenWidth-90, 20)];
        _freightLB.font = FontSet(14);
        _freightLB.textColor = MainBlackTextColor;
        _freightLB.textAlignment = NSTextAlignmentLeft;
        _freightLB.text = @"包邮";
    }
    return _freightLB;
}

//发货地
- (UILabel *)deliveryLB{
    if (!_deliveryLB) {
        _deliveryLB = [[UILabel alloc] initWithFrame:CGRectMake(self.leftDeliveryLB.right+20, self.leftDeliveryLB.top, ScreenWidth-90, 20)];
        _deliveryLB.font = FontSet(14);
        _deliveryLB.textColor = MainBlackTextColor;
        _deliveryLB.textAlignment = NSTextAlignmentLeft;
        _deliveryLB.text = @"选择地址";
    }
    return _deliveryLB;
}
#pragma mark - SEL
-(void)tapClick:(UIGestureRecognizer *)ges{
    if (self.chooseGoodSkuBlock) {
        self.chooseGoodSkuBlock();
    }
}


@end
